-
Notifications
You must be signed in to change notification settings - Fork 985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement getSuggestedRoutes endpoint in the Send Flow for wallet #18104
Conversation
Jenkins BuildsClick to see older builds (64)
|
d281f5f
to
abec7a7
Compare
(cond loading-suggested-routes? | ||
[quo/text "Loading routes"] | ||
(and (not loading-suggested-routes?) route) | ||
[quo/text "Route found"] | ||
(and (not loading-suggested-routes?) (nil? route)) | ||
[quo/text "Route not found"])] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is temporary, should be addressed in #16929
5eceecf
to
fa46e05
Compare
@@ -390,3 +390,15 @@ | |||
(def ^:const account-default-customization-color :blue) | |||
|
|||
(def ^:const wallet-account-name-max-length 20) | |||
|
|||
(def ^:const gas-rate-low 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌
src/utils/money.cljs
Outdated
@@ -205,10 +205,14 @@ | |||
(with-precision 2) | |||
str)) | |||
|
|||
(defn add | |||
(defn- add* | |||
[bn1 n2] | |||
(.add ^js bn1 n2)) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not for now, but these methods should probably all be covered in tests. We can add this as part of the post 1.27 workset 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it (and explained why) in a previous PR.
I can add some tests in a following PR @J-Son89
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ulisesmac - I was making no comment about the added function, I understand the use case. My point is more that we are using a bunch of (afaik) untested utilities that handle numbers. Tests would be great but we can wait until post 1.27 as let's focus on the delivering those features to the best quality as possible :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes, that's true!, we are relying on the functions in this namespace. They need to be tested.
@@ -48,7 +48,7 @@ | |||
:<- [:wallet/balances] | |||
:<- [:wallet/tokens-loading?] | |||
(fn [[accounts balances tokens-loading?]] | |||
(mapv (fn [{:keys [color address type] :as account}] | |||
(mapv (fn [{:keys [color address] :as account}] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you remove type? it's needed on line 54?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should destructure this map in another way, so that the app doesn't compile if the var doesn't exist.
(mapv (fn [{:keys [color address]
account-type :type
:as account}]
,,,
;;line 54:
:type (if (= account-type :watch) :watch-only :empty)
,,,)
[,,,])
currently the app is compiling but in the line 54: (= type :watch)
is always going to be false
.
Just to give a little more of context on it in case it's needed:
(= type :watch)
;; => false
type
;; => #object[cljs$core$type]
token-id (:symbol token) | ||
network-preferences [constants/mainnet-chain-id] ; TODO: don't hardcode network preferences | ||
gas-rates constants/gas-rate-low | ||
amount-in (money/mul (money/bignumber amount) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be better to make amount-in a helper fn?
(defn amount-in-hex [amount token-decimal]
(money/to-hex-in (money/mul (money/bignumber amount) (money/from-decimal token-decimal)))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the same, as a named function it'll be clearer what these calculations mean 👍
|
||
(defn amount-in-hex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A test can be added for this function
58% of end-end tests have passed
Failed tests (15)Click to expandClass TestGroupChatMultipleDeviceMergedNewUI:
Class TestOneToOneChatMultipleSharedDevicesNewUi:
Class TestActivityCenterContactRequestMultipleDevicePR:
Class TestCommunityOneDeviceMerged:
Expected to fail tests (5)Click to expandClass TestOneToOneChatMultipleSharedDevicesNewUi:
Class TestGroupChatMultipleDeviceMergedNewUI:
Class TestCommunityMultipleDeviceMergedTwo:
Class TestCommunityMultipleDeviceMerged:
Class TestCommunityOneDeviceMerged:
Passed tests (28)Click to expandClass TestActivityMultipleDevicePR:
Class TestDeepLinksOneDevice:
Class TestActivityCenterContactRequestMultipleDevicePR:
Class TestOneToOneChatMultipleSharedDevicesNewUiTwo:
Class TestCommunityMultipleDeviceMerged:
Class TestCommunityMultipleDeviceMergedTwo:
Class TestActivityMultipleDevicePRTwo:
Class TestCommunityOneDeviceMerged:
|
75% of end-end tests have passed
Failed tests (5)Click to expandClass TestCommunityOneDeviceMerged:
Class TestActivityMultipleDevicePRTwo:
Class TestActivityMultipleDevicePR:
Expected to fail tests (7)Click to expandClass TestCommunityOneDeviceMerged:
Class TestOneToOneChatMultipleSharedDevicesNewUi:
Class TestCommunityMultipleDeviceMergedTwo:
Class TestGroupChatMultipleDeviceMergedNewUI:
Class TestOneToOneChatMultipleSharedDevicesNewUiTwo:
Class TestCommunityMultipleDeviceMerged:
Passed tests (36)Click to expandClass TestCommunityOneDeviceMerged:
Class TestOneToOneChatMultipleSharedDevicesNewUi:
Class TestCommunityMultipleDeviceMergedTwo:
Class TestDeepLinksOneDevice:
Class TestGroupChatMultipleDeviceMergedNewUI:
Class TestOneToOneChatMultipleSharedDevicesNewUiTwo:
Class TestCommunityMultipleDeviceMerged:
Class TestActivityCenterContactRequestMultipleDevicePR:
|
1d63ee8
to
21dcda2
Compare
21dcda2
to
dc3bf43
Compare
100% of end-end tests have passed
Passed tests (5)Click to expandClass TestActivityMultipleDevicePRTwo:
Class TestCommunityOneDeviceMerged:
Class TestActivityMultipleDevicePR:
|
dc3bf43
to
05fd97e
Compare
Hey. @briansztamfater the routes are not found in my cases. But I have some real tokens on mainnet, optimizm, arbitrium networks. What I am doing wrong? Actual result:route.mp4Expected result:Route is found Logs: |
Question 1: Should this feature work in case of founding the route for testnet tokens? For now it does not work Steps:
Actual result:The route is not found goerli.mp4Expected result:Should the rout be found? |
Hi @VolodLytvynenko, that should at least work. This is the happy path for finding the best route for a transaction. I tested yesterday evening and it was working okay for me. Is it working on mainnet? |
@J-Son89 Yes, I tried it on the Mainnet network without any success to get the route, even when entering the minimum amount. |
@J-Son89 Have I understood the requirements correctly regarding route finding within the scope of this PR? The route should always be found if the user has enough assets on all networks. For instance: However, in the case of entering an amount higher than available, for example, '3.0001 ETH,' the route should not be found. Is there a minimum amount for a particular asset that determines whether a route should or should not be found? Or in the scope of this PR would be enough to see the route is found at least once to achieve the happy path? |
Hey @VolodLytvynenko - i.e It is mostly just for Ethereum tokens (other tokens should work too), It is only a single token transaction, i.e you are sending eth so you will then pay gas in eth and not in other tokens. The amount entered is in crypto, we will handle the fiat conversion in another issue too. |
@briansztamfater @J-Son89 No issues from my side. The happy flow works. Follow ups I will add separately Ready to be merged |
Signed-off-by: Brian Sztamfater <brian@status.im>
05fd97e
to
e541a2a
Compare
fixes #18201
Summary
This PR includes token amount selection screen into the Send flow and implements getSuggestedRoutes endpoint, which based on the response can enable the Confirm button to proceed to Transaction Confirmation Screen (to be implemented in a follow up PR)
suggestedroutesdemo.mp4
Platforms
Areas that maybe impacted
Functional
Steps to test
status: ready